*********************************************************************************************************
*                                                                                                       *
* How Peace Agreements Influence National Climate Policy                                                * 
*                                                                                                       *
* Tobias Böhmelt                                                                                        *
*                                                                                                       *
* Address Correspondance to: tbohmelt@essex.ac.uk                                                       *
*                                                                                                       *
* This Version: November 23, 2025                                                                       *
*                                                                                                       *
*********************************************************************************************************

********************
* Data Preparation *
********************

use "JCR Replication Climate Policies.dta", clear
xtset ccode year

**************************
* Descriptive Statistics *
**************************

sum climate_policies LDV cum_sum_env gdp_pc_ln gdp_pc_ln2 pop_ln democracy globalization if env_ref!=.

gen conflict=1 if ucdp_type2!=.
replace conflict=1 if ucdp_type3!=.
replace conflict=1 if ucdp_type4!=.
egen count_conflict=sum(policies_all) if conflict==1 & env_ref==. & year>1989, by(year)
egen count_agreements=sum(policies_all) if env_ref!=., by(year)
twoway (mband count_conflict year) (mband count_agreements year), xlabel(1990(5)2025) legend(off) scheme(538w) aspectratio(1)

preserve
use "Climate Policies Disaggregated.dta", clear
graph pie if sample_identifier==1, over(sector) scheme(538w)
tab sector if sample_identifier==1
restore

***********************
* Main Effects Models *
***********************

eststo clear
eststo: xtreg climate_policies cum_sum_env i.year, fe
estimates store reg1
eststo: xtreg climate_policies cum_sum_env c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg2
eststo: xtreg climate_policies LDV cum_sum_env i.year, fe
estimates store reg3
eststo: xtreg climate_policies LDV cum_sum_env c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg4
eststo: xtreg climate_policies LDV l.cum_sum_env i.year, fe
estimates store reg5
eststo: xtreg climate_policies LDV l.cum_sum_env c.l.gdp_pc_ln##c.l.gdp_pc_ln l.pop_ln l.democracy l.globalization i.year, fe 
estimates store reg6
esttab reg1 reg2 reg3 reg4 reg5 reg6, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model 1" "Model 2" "Model 3" "Model 4" "Model 5" "Model 6") 

**************************************
* Substantive Quantities of Interest *
**************************************

preserve
tab year, gen(year_fe)
tab ccode, gen(country_fe)
estsimp reg climate_policies LDV cum_sum_env gdp_pc_ln gdp_pc_ln2 pop_ln democracy globalization year_fe* country_fe* 
sum b2, detail
local x1 `r(mean)'
kdensity b2, xli(`x1', lcolor(gs10) lpattern(dash)) legend(off) scheme(538w) aspectratio(1) title("") xtitle("Simulated Effect") legend(off) note("") name(graph1, replace)
restore

xtreg climate_policies LDV cum_sum_env c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
margins, at(cum_sum_env=(0(5)35)) level(95)
marginsplot, recast(line) ciopts(recast(rline) lpattern(dash)) level(95) legend(off) xlabel(0(5)35) scheme(538w) aspectratio(1) ytitle("Climate Policies") title("") name(graph2, replace)

****************************
* Within-Between Estimator *
****************************

global MLwiN_path "mlwin.exe"

preserve
drop if missing(cum_sum_env)
gen cons=1
sort ccode
egen LDV_mean = mean(LDV), by(ccode)
gen LDVw = LDV - LDV_mean
egen cum_sum_env_mean = mean(cum_sum_env), by(ccode)
gen cum_sum_envw = cum_sum_env - cum_sum_env_mean
iis ccode
tis year
runmlwin climate_policies cons LDV_mean LDVw cum_sum_env_mean cum_sum_envw i.year, level2(ccode: cons) level1(year: cons) nopause rigls
restore

preserve
drop if missing(cum_sum_env)
drop if missing(gdp_pc_ln)
drop if missing(gdp_pc_ln2)
drop if missing(pop_ln)
drop if missing(democracy)
drop if missing(globalization)
gen cons=1
sort ccode
egen LDV_mean = mean(LDV), by(ccode)
gen LDVw = LDV - LDV_mean
egen cum_sum_env_mean = mean(cum_sum_env), by(ccode)
gen cum_sum_envw = cum_sum_env - cum_sum_env_mean
egen gdp_pc_ln_mean = mean(gdp_pc_ln), by(ccode)
gen gdp_pc_lnw = gdp_pc_ln - gdp_pc_ln_mean
egen gdp_pc_ln2_mean = mean(gdp_pc_ln2), by(ccode)
gen gdp_pc_ln2w = gdp_pc_ln2 - gdp_pc_ln2_mean
egen pop_ln_mean = mean(pop_ln), by(ccode)
gen pop_lnw = pop_ln - pop_ln_mean
egen democracy_mean = mean(democracy), by(ccode)
gen democracyw = democracy - democracy_mean
egen globalization_mean = mean(globalization), by(ccode)
gen globalizationw = globalization - globalization_mean
iis ccode
tis year
runmlwin climate_policies cons LDV_mean LDVw cum_sum_env_mean cum_sum_envw gdp_pc_ln_mean gdp_pc_lnw gdp_pc_ln2_mean gdp_pc_ln2w pop_ln_mean pop_lnw democracy_mean democracyw globalization_mean globalizationw i.year, level2(ccode: cons) level1(year: cons) nopause rigls
restore

***********************************
* General Error Correction Models *
***********************************

eststo clear
eststo: xtreg d.climate_policies LDV d.cum_sum_env l.cum_sum_env i.year, fe
estimates store reg9
eststo: xtreg d.climate_policies LDV d.cum_sum_env l.cum_sum_env c.d.gdp_pc_ln##c.d.gdp_pc_ln c.l.gdp_pc_ln##c.l.gdp_pc_ln d.pop_ln l.pop_ln d.democracy l.democracy d.globalization l.globalization i.year, fe
estimates store reg10
esttab reg9 reg10, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model 9" "Model 10") 

preserve
gen dclimate_policies = d.climate_policies
gen lclimate_policies = l.climate_policies
gen d_cum_sum_env = d.cum_sum_env
gen l_cum_sum_env = l.cum_sum_env
dynsim_pcse, dv(climate_policies) ldv(lclimate_policies) ldv_val(0) time(year) pv(ccode) scen1(d_cum_sum_env 0 l_cum_sum_env 0) scen2(d_cum_sum_env 1 l_cum_sum_env 1) command(regress) sims(1000)  ///
	n(9) scheme(538w) ytitle ("Climate Policies") legend(label(1 "Environmental Provisions = 0") label(2 "Environmental Provisions = 1")) xtitle("Year + t")
restore

***********************
* Additional Analyses *
***********************

preserve
eststo clear
replace climate_policies=ln(1+policy_climate)
replace LDV=l.policy_climate
eststo: xtreg climate_policies LDV cum_sum_env c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg11
esttab reg11, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model 11")
restore

preserve
eststo clear
gen co2=ln(1+wdi_co2)
eststo: xtreg co2 l.co2 cum_sum_env c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg12
esttab reg12, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model 12")  
restore

preserve
xtile state_capacity_dummy = icrg_qog, nq(2) 
replace state_capacity_dummy=state_capacity_dummy-1
eststo clear
eststo: xtreg climate_policies LDV c.cum_sum_env##i.state_capacity_dummy c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg13
gen co2=ln(1+wdi_co2)
eststo: xtreg co2 l.co2 c.cum_sum_env##i.state_capacity_dummy c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg14
esttab reg13 reg14, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model 13" "Model 14") 
restore

preserve
eststo clear
eststo: xtreg climate_policies LDV cum_sum_env civil_conflict c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg15
eststo: xtreg climate_policies LDV c.cum_sum_env c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year if civil_conflict==1, fe 
estimates store reg16
esttab reg15 reg16, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model 15" "Model 16") 
restore

preserve
gen general_aid=genaid_millions
replace general_aid=0 if general_aid<0 & general_aid!=.
replace general_aid=ln(1+general_aid)
replace general_aid=0 if cum_sum_env!=. & general_aid==.
eststo clear
eststo: xtreg climate_policies LDV c.cum_sum_env##c.general_aid c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg17
eststo: xtreg climate_policies LDV c.cum_sum_env##i.UN_involvement c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg18
eststo: xtreg climate_policies LDV c.cum_sum_env##i.power_participation c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store reg19
esttab reg17 reg18 reg19, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model 17" "Model 18" "Model 19") 
restore

*********************
* Robustness Checks *
*********************

preserve
eststo clear
eststo: xtreg climate_policies LDV env_ref c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store regA1
esttab regA1, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model A1") 
restore

preserve
keep if cum_sum_env!=.
fect climate_policies, treat(env_ref) unit(ccode) time(year) cov(LDV gdp_pc_ln gdp_pc_ln2 pop_ln democracy globalization) method("fe") force("two-way") se  
mat list e(ATT)
mat list e(ATTs)
mat list e(coefs)   
fect climate_policies, treat(env_ref) unit(ccode) time(year) cov(LDV) method("fe") force("two-way") se placeboTest 
fect climate_policies, treat(env_ref) unit(ccode) time(year) cov(LDV) method("fe") force("two-way") se equiTest 
fect climate_policies, treat(env_ref) unit(ccode) time(year) cov(LDV) method("fe") force("two-way") se carryoverTest 
restore

preserve
btscs env_ref year ccode, g(env_ref_yrs)
sum env_ref_yrs
replace env_ref_yrs=r(max)-env_ref_yrs
eststo clear
eststo: xtreg climate_policies LDV env_ref_yrs c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store regA3
esttab regA3, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model A3") 
restore

preserve
btscs env_ref year ccode, g(env_ref_yrs)
gen disaster_new=ln(1+ totaldeaths)
eststo clear
eststo: heckman climate_policies LDV cum_sum_env c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy i.ccode, select(env_ref= disaster_new globalization c.env_ref_yrs##c.env_ref_yrs##c.env_ref_yrs)
estimates store regA4
esttab regA4, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.ccode) nonumbers mtitles("Model A4")  
restore

preserve
gen rc_government=1 if execrlc==1
replace rc_government=1 if gov1rlc==1
replace rc_government=1 if execrlc==2
replace rc_government=1 if gov1rlc==2
replace rc_government=0 if rc_government==. & execrlc!=.
eststo clear
eststo: xtreg climate_policies LDV c.cum_sum_env##i.rc_government c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store regA5
esttab regA5, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model A5") 
restore

preserve
replace democracy=1 if democracy>0.5 & democracy!=.
replace democracy=0 if democracy<=0.5 & democracy!=.
eststo clear
eststo: xtreg climate_policies LDV c.cum_sum_env##i.democracy c.gdp_pc_ln##c.gdp_pc_ln pop_ln globalization i.year, fe 
estimates store regA6
esttab regA6, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model A6")
restore

preserve
eststo clear
eststo: xtreg climate_policies LDV cum_sum_env recur c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year, fe 
estimates store regA7
eststo: xtreg climate_policies LDV cum_sum_env c.gdp_pc_ln##c.gdp_pc_ln pop_ln democracy globalization i.year if recur==0, fe 
estimates store regA8
esttab regA7 regA8, replace stats(N, fmt(%9.0fc) labels("Observations")) se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label drop(*.year) nonumbers mtitles("Model A7" "Model A8") 
restore
